﻿using B.S.GridManager.Api.Write.Application.Command.PhsicalGrid;
using B.S.GridManager.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.GridManager.Api.Write.Controllers
{
    /// <summary>
    /// 物理网格控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhysicalController : ControllerBase
    {
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数注入中介者
        /// </summary>
        /// <param name="mediator">中介者对象</param>
        public PhysicalController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 创建物理网格接口
        /// </summary>
        /// <param name="request">添加物理网格请求参数</param>
        /// <returns>通用的包装响应</returns>
        [HttpPost]
        public Task<ApiResult<int>> CreatePhysicalGrid(CreatePhysicalGridCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        ///  更新物理网格接口
        /// </summary>
        /// <param name="request">更新物理网格请求参数</param>
        /// <returns>通用的包装响应</returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdatePhsicalGrid(UpdatePhsicalGridCommand request) {
            return mediator.Send(request);
        }
        /// <summary>
        /// 逻辑删除物理网格接口
        /// </summary>
        /// <param name="request">删除物理网格请求参数</param>
        /// <returns>通用的包装响应</returns>
        [HttpPut]
        public Task<ApiResult<int>> DelPhysicalGrid(DelPhysicalGridCommand request) {
            return mediator.Send(request);
        }
    }
}
